home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
DEMON
/
RISCOS2
/
TCP_131S.ARC
/
c
/
iface
< prev
next >
Wrap
Text File
|
1993-12-22
|
2KB
|
57 lines
#include <stdio.h>
#include <string.h>
#include "global.h"
#include "iface.h"
#include "misc.h"
struct interface *if_lookup(char *name)
{
register struct interface *iface;
for(iface = ifaces; iface != NULLIF; iface = iface->next)
if(strcmp(iface->name,name) == 0)
break;
return iface;
}
/* Divert output packets from one interface to another. Useful for ARP
* and digipeat frames coming in from receive-only interfaces
*/
int doforward(int argc, char **argv)
{
struct interface *iface,*iface1;
if(argc < 2){
for(iface = ifaces; iface != NULLIF; iface = iface->next){
if(iface->forw != NULLIF){
cwprintf(NULL, "%s -> %s\r\n",iface->name,iface->forw->name);
}
}
return 0;
}
if((iface = if_lookup(argv[1])) == NULLIF){
cwprintf(NULL, "Interface %s unknown\r\n",argv[1]);
return 1;
}
if(argc < 3){
if(iface->forw == NULLIF)
cwprintf(NULL, "%s not forwarded\r\n",iface->name);
else
cwprintf(NULL, "%s -> %s\r\n",iface->name,iface->forw->name);
return 0;
}
if((iface1 = if_lookup(argv[2])) == NULLIF){
cwprintf(NULL, "Interface %s unknown\r\n",argv[2]);
return 1;
}
if(iface1 == iface){
/* Forward to self means "turn forwarding off" */
iface->forw = NULLIF;
} else {
if(iface1->output != iface->output)
cwprintf(NULL, "Warning: Interfaces of different type\r\n");
iface->forw = iface1;
}
return 0;
}